import type { IColumnsOption } from 'vc';
import { INDEX } from '@/utils/tableColumn';

export function useTable() {
  
  const columns = ref<Nullable<IColumnsOption>[]>([
    { ...INDEX },
    {
      title: '颁证日期',
      field: 'issuingDate',
      sortable: true,
      headerAlign: 'center',
      width: 111
    },
    {
      title: '资质名称',
      field: 'certificationProgram',
      headerAlign: 'center',
      slots: {
        default: ({ row }) => {
          return  <>
            <span class="">{row?.certificationProgram}</span>
            <span class="text-[#8B8C8C] ml-10px">{row?.certificationEngName}</span>
          </>;
        }
      }
    },
    {
      title: '有效期',
      field: 'expirationDate',
      width: 151,
      sortable: true,
      slots: {
        default: ({ row }) => {
          const { bgColor, color, name } = row?.label;
          return  <>
            <div class="date">
              <span class="text">{row.expirationDate}</span>
              <span class="py-1px px-7px ml-10px" style={{ color: color, backgroundColor: bgColor }}>
                {name}
              </span>
            </div>
          </>;
        }
      }
    },
    {
      title: '证书编号',
      width: 190,
      sortable: true,
      field: 'certificateNumber'
    },
    {
      title: '认证单位',
      width: 161,
      sortable: true,
      field: 'issuingDepartment'
    },
    {
      title: '初次获证日期',
      width: 111,
      sortable: true,
      field: 'firstCertificationDate'
    }
  ]);
  
  return {
    columns
  };
}
